function validateEmail(email) {
	var re = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
	
	return re.test(email);
}

function validateLogin() {
	var form = documents.forms["login"];
	
	var login = form["login"].value;
	var pwd = form["pwd"].value;
	
	if (login == "" || pwd == "") {
		alert("Invalid fields.");
		return false;
	}
	
	return true;
}

function validateForm() {
	var form = document.forms["signup"];
	
	var login = form["login"].value;
	var fname = form["fname"].value;
	var lname = form["lname"].value;
	var email = form["email"].value;
	var cc = form["cc"].value;
	var addr = form["address"].value;
	var pwd = form["pwd"].value;
	var cpwd = form["conf_pwd"].value;
	
	if (login == "" || fname == "" || lname == "" || email == "" || pwd == "" || cpwd == "" || cc == "" || addr == "") {
		alert("Invalid fields.");
		return false;
	}
	
	if (pwd != cpwd) {
		alert("Passwords don't match.");
		return false;
	}
	
	if (pwd.length < 8) {
		alert("Password is too short.");
		return false;
	}
	
	if (!validateEmail(email)) {
		alert("Invalid email.");
		return false;
	}
	
	if (!(/^\d*$/.test(cc))) {
		alert("Invalid credit card number.");
		return false;
	}
	
	return true;
}
